import 'package:json_annotation/json_annotation.dart';

import 'area_style.dart';
import 'axis_pointer.dart';
import 'line_style.dart';
import 'text_style.dart';

part 'axis.g.dart';

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class AxisLine {
  var show;
  var onZero;
  var onZerAxisIndex;
  var symbol;
  var symbolSize;
  var symbolOffset;
  LineStyle? lineStyle;

  AxisLine(
      {this.show,
      this.onZero,
      this.onZerAxisIndex,
      this.symbol,
      this.symbolSize,
      this.symbolOffset,
      this.lineStyle});

  factory AxisLine.fromJson(Map<String, dynamic> json) =>
      _$AxisLineFromJson(json);

  Map<String, dynamic> toJson() => _$AxisLineToJson(this);
}

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class AxisTick {
  var show;
  var alignWithLabel;
  var interval; //varber Function  (index:varber, value: var) => varean
  var inside;
  var length;
  LineStyle? lineStyle;

  AxisTick(
      {this.show,
      this.alignWithLabel,
      this.interval,
      this.inside,
      this.length,
      this.lineStyle});

  factory AxisTick.fromJson(Map<String, dynamic> json) =>
      _$AxisTickFromJson(json);

  Map<String, dynamic> toJson() => _$AxisTickToJson(this);
}

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class MinorTick {
  var show;
  var splitNumber;
  var length;
  LineStyle? lineStyle;

  MinorTick({this.show, this.splitNumber, this.length, this.lineStyle});

  factory MinorTick.fromJson(Map<String, dynamic> json) =>
      _$MinorTickFromJson(json);

  Map<String, dynamic> toJson() => _$MinorTickToJson(this);
}

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class AxisLabel {
  var show;
  var interval; //varber Function  (index:varber, value: var) => varean
  var inside;
  var rotate;
  var margin;
  var formatter;
  var showMinLabel;
  var showMaxLabel;
  var color;
  var fontStyle;
  var fontWeight;
  var fontFamily;
  var fontSize;
  var align;
  var verticalAlign;
  var lineHeight;
  var backgroundColor;
  var borderColor;
  var borderWidth;
  var borderRadius;
  var padding;
  var shadowColor;
  var shadowOffsetX;
  var shadowOffsetY;
  var width;
  var height;

  var textBorderColor;

  var textBorderWidth;
  var textShadowColor;
  var textShadowBlur;
  var textShadowOffsetX;
  var textShadowOffsetY;
  var overFlow;
  var ellipsis;
  var lineOverflow;
  var rich;

  AxisLabel(
      {this.show,
      this.interval,
      this.inside,
      this.rotate,
      this.margin,
      this.formatter,
      this.showMinLabel,
      this.showMaxLabel,
      this.color,
      this.fontStyle,
      this.fontWeight,
      this.fontFamily,
      this.fontSize,
      this.align,
      this.verticalAlign,
      this.lineHeight,
      this.backgroundColor,
      this.borderColor,
      this.borderWidth,
      this.borderRadius,
      this.padding,
      this.shadowColor,
      this.shadowOffsetX,
      this.shadowOffsetY,
      this.width,
      this.height,
      this.textBorderColor,
      this.textBorderWidth,
      this.textShadowColor,
      this.textShadowBlur,
      this.textShadowOffsetX,
      this.textShadowOffsetY,
      this.overFlow,
      this.ellipsis,
      this.lineOverflow,
      this.rich});

  factory AxisLabel.fromJson(Map<String, dynamic> json) =>
      _$AxisLabelFromJson(json);

  Map<String, dynamic> toJson() => _$AxisLabelToJson(this);
}

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class SplitLine {
  var show;
  var interval;
  LineStyle? lineStyle;

  SplitLine({this.show, this.interval, this.lineStyle});

  factory SplitLine.fromJson(Map<String, dynamic> json) =>
      _$SplitLineFromJson(json);

  Map<String, dynamic> toJson() => _$SplitLineToJson(this);
}

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class MinorSplitLine {
  var show;
  LineStyle? lineStyle;

  MinorSplitLine({this.show, this.lineStyle});

  factory MinorSplitLine.fromJson(Map<String, dynamic> json) =>
      _$MinorSplitLineFromJson(json);

  Map<String, dynamic> toJson() => _$MinorSplitLineToJson(this);
}

///**********Area*********** */

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class SplitArea {
  var interval;
  var show;
  AreaStyle? areaStyle;

  SplitArea({this.interval, this.show, this.areaStyle});

  factory SplitArea.fromJson(Map<String, dynamic> json) =>
      _$SplitAreaFromJson(json);

  Map<String, dynamic> toJson() => _$SplitAreaToJson(this);
}

///********************* */

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class AxisData {
  var value;
  TextStyle? textStyle;

  AxisData({this.value, this.textStyle});

  factory AxisData.fromJson(Map<String, dynamic> json) =>
      _$AxisDataFromJson(json);

  Map<String, dynamic> toJson() => _$AxisDataToJson(this);
}

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class Axis {
  var id;
  var show;
  var gridIndex;
  var position; //'top' 'bottom'
  var offset;
  var realtimeSort;
  var sortSeriesIndex;
  var type;
  var name;
  var nameLocation; //'start' 'middle' or 'center''end'
  TextStyle? nameTextStyle;
  var nameGap;
  var nameRotate;
  var inverse;
  var boundaryGap; //be set to either true or false or ['20%', '20%']

  var min; //varber var Function
  var max; //varber var Function
  var scale;
  var splitNumber;
  var minInterval;
  var maxInterval;
  var interval;
  var logBase;
  var silent;
  var triggerEvent;
  AxisLine? axisLine;
  AxisTick? axisTick;
  MinorTick? minorTick;
  AxisLabel? axisLabel;
  SplitLine? splitLine;
  MinorSplitLine? minorSplitLine;
  SplitArea? splitArea;
  List<AxisData>? data;
  AxisPointer? axisPointer;
  var zlvel;
  var z;

//radiusAxis中多项
  var polarIndex;

  //angleAxis中多项
  var startAngle;
  var clockwise;

  Axis(
      {this.id,
      this.show,
      this.gridIndex,
      this.position,
      this.offset,
      this.realtimeSort,
      this.sortSeriesIndex,
      this.type,
      this.name,
      this.nameLocation,
      this.nameTextStyle,
      this.nameGap,
      this.nameRotate,
      this.inverse,
      this.boundaryGap,
      this.min,
      this.max,
      this.scale,
      this.splitNumber,
      this.minInterval,
      this.maxInterval,
      this.interval,
      this.logBase,
      this.silent,
      this.triggerEvent,
      this.axisLine,
      this.axisTick,
      this.minorTick,
      this.axisLabel,
      this.splitLine,
      this.minorSplitLine,
      this.splitArea,
      this.data,
      this.axisPointer,
      this.zlvel,
      this.z,
      this.polarIndex,
      this.startAngle,
      this.clockwise});

  factory Axis.fromJson(Map<String, dynamic> json) => _$AxisFromJson(json);

  Map<String, dynamic> toJson() => _$AxisToJson(this);
}
